#include<stdio.h>
#include<stdlib.h>
#include<time.h>

#define N 10

int select_sort(int arr[], int n);
int main(int argc, char *argv[])
{
	srand(time(NULL));

	int arr[N] = {0};

	for(int i = 0; i < N; i++){
		arr[i] = rand()%100;
		printf("%d ", arr[i]);
	}
	printf("\n");
	select_sort(arr, N);
	for(int i = 0; i < N; i++){
		printf("%d ", arr[i]);
	}

	return 0;
}

int select_sort(int arr[], int n){
	int tem;
	for(int i = 0; i < n-1; i++){
		int max = i;
		for(int j = i + 1; j < n; j++){
			if(arr[j] > arr[max]){
				max = j;
			}
		}
		if(max!=i){
			tem = arr[i];
			arr[i] = arr[max];
			arr[max] = tem;
		}
	}

	return 0;
}
